ds_stack_pop

Pops the value from the top of the stack.

语法:

ds_stack_pop(id);


参数 描述
id The id of the data structure to pop from.


Returns: Real, String, undefined


描述

This function will pop the top value off of the ds_stack, removing it from the stack and returning the value to be stored in a variable. If the stack is empty then the function will return the constant undefined, otherwise it will return the real or string value contained in the stack.


例如:

if !ds_stack_empty(move_stack)
   {
   var xx, yy;
   xx = ds_stack_pop(move_stack);
   yy = ds_stack_pop(move_stack);
   move_towards_point(xx, yy, 4);
   }

The above code checks the ds_stack indexed in the variable "move_stack" to see if it is empty, and if it is not, it then pops the top two values from the stack and use them to set a direction for movement.


上一页: Stacks
下一页: ds_stack_push
© Copyright YoYo Games Ltd. 2018 All Rights Reserved